<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
  <meta charset="utf-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  
  <title>生成查询结果 &mdash; CodeIgniter 3.0.0 中文手册|用户手册|用户指南|中文文档</title>
  

  
  
  <link rel="shortcut icon" href="../_static/ci-icon.ico" />
  

  
  <link href="../_static/css/fonts.css" rel="stylesheet" type="text/css" />

  
  
    

  

  
  
  <link rel="stylesheet" href="../_static/css/theme.css" type="text/css" />
  

  
  <link rel="stylesheet" href="../_static/css/theme_cn.css" type="text/css" />
    <link rel="top" title="CodeIgniter 3.0.0 中文手册|用户手册|用户指南|中文文档" href="../index.html"/>
        <link rel="up" title="数据库参考" href="index.html"/>
        <link rel="next" title="查询辅助函数" href="helpers.html"/>
        <link rel="prev" title="查询" href="queries.html"/> 

  
  <script src="../_static/js/modernizr.2.6.2.min.js"></script>

</head>

<body class="wy-body-for-nav" role="document">

  <div id="nav">
  <div id="nav_inner">
    
    
    
      <div id="pulldown-menu" class="ciNav">
        <ul>
<li class="toctree-l1"><a class="reference internal" href="../general/welcome.html">欢迎使用 CodeIgniter</a><ul class="simple">
</ul>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../installation/index.html">安装说明</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../installation/downloads.html">下载 CodeIgniter</a></li>
<li class="toctree-l2"><a class="reference internal" href="../installation/index.html">安装说明</a></li>
<li class="toctree-l2"><a class="reference internal" href="../installation/upgrading.html">从老版本升级</a></li>
<li class="toctree-l2"><a class="reference internal" href="../installation/troubleshooting.html">疑难解答</a></li>
</ul>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../overview/index.html">CodeIgniter 概览</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../overview/getting_started.html">开始</a></li>
<li class="toctree-l2"><a class="reference internal" href="../overview/at_a_glance.html">CodeIgniter 是什么？</a></li>
<li class="toctree-l2"><a class="reference internal" href="../overview/features.html">支持特性</a></li>
<li class="toctree-l2"><a class="reference internal" href="../overview/appflow.html">应用程序流程图</a></li>
<li class="toctree-l2"><a class="reference internal" href="../overview/mvc.html">模型 - 视图 - 控制器</a></li>
<li class="toctree-l2"><a class="reference internal" href="../overview/goals.html">架构目标</a></li>
</ul>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../tutorial/index.html">教程 - 内容提要</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../tutorial/static_pages.html">加载静态内容</a></li>
<li class="toctree-l2"><a class="reference internal" href="../tutorial/news_section.html">读取新闻条目</a></li>
<li class="toctree-l2"><a class="reference internal" href="../tutorial/create_news_items.html">创建新闻条目</a></li>
<li class="toctree-l2"><a class="reference internal" href="../tutorial/conclusion.html">结束语</a></li>
</ul>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../contributing/index.html">向 CodeIgniter 贡献你的力量</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../documentation/index.html">编写 CodeIgniter 的文档</a></li>
<li class="toctree-l2"><a class="reference internal" href="../DCO.html">Developer's Certificate of Origin 1.1</a></li>
</ul>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../general/index.html">常规主题</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../general/urls.html">CodeIgniter URL</a></li>
<li class="toctree-l2"><a class="reference internal" href="../general/controllers.html">控制器</a></li>
<li class="toctree-l2"><a class="reference internal" href="../general/reserved_names.html">保留名称</a></li>
<li class="toctree-l2"><a class="reference internal" href="../general/views.html">视图</a></li>
<li class="toctree-l2"><a class="reference internal" href="../general/models.html">模型</a></li>
<li class="toctree-l2"><a class="reference internal" href="../general/helpers.html">辅助函数</a></li>
<li class="toctree-l2"><a class="reference internal" href="../general/libraries.html">使用 CodeIgniter 类库</a></li>
<li class="toctree-l2"><a class="reference internal" href="../general/creating_libraries.html">创建类库</a></li>
<li class="toctree-l2"><a class="reference internal" href="../general/drivers.html">使用 CodeIgniter 驱动器</a></li>
<li class="toctree-l2"><a class="reference internal" href="../general/creating_drivers.html">创建驱动器</a></li>
<li class="toctree-l2"><a class="reference internal" href="../general/core_classes.html">创建核心系统类</a></li>
<li class="toctree-l2"><a class="reference internal" href="../general/ancillary_classes.html">创建附属类</a></li>
<li class="toctree-l2"><a class="reference internal" href="../general/hooks.html">钩子 - 扩展框架核心</a></li>
<li class="toctree-l2"><a class="reference internal" href="../general/autoloader.html">自动加载资源</a></li>
<li class="toctree-l2"><a class="reference internal" href="../general/common_functions.html">公共函数</a></li>
<li class="toctree-l2"><a class="reference internal" href="../general/compatibility_functions.html">兼容性函数</a></li>
<li class="toctree-l2"><a class="reference internal" href="../general/routing.html">URI 路由</a></li>
<li class="toctree-l2"><a class="reference internal" href="../general/errors.html">错误处理</a></li>
<li class="toctree-l2"><a class="reference internal" href="../general/caching.html">网页缓存</a></li>
<li class="toctree-l2"><a class="reference internal" href="../general/profiling.html">程序分析</a></li>
<li class="toctree-l2"><a class="reference internal" href="../general/cli.html">以 CLI 方式运行</a></li>
<li class="toctree-l2"><a class="reference internal" href="../general/managing_apps.html">管理你的应用程序</a></li>
<li class="toctree-l2"><a class="reference internal" href="../general/environments.html">处理多环境</a></li>
<li class="toctree-l2"><a class="reference internal" href="../general/alternative_php.html">在视图文件中使用 PHP 替代语法</a></li>
<li class="toctree-l2"><a class="reference internal" href="../general/security.html">安全</a></li>
<li class="toctree-l2"><a class="reference internal" href="../general/styleguide.html">PHP 开发规范</a></li>
</ul>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../libraries/index.html">类库参考</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../libraries/benchmark.html">基准测试类</a></li>
<li class="toctree-l2"><a class="reference internal" href="../libraries/caching.html">缓存驱动器</a></li>
<li class="toctree-l2"><a class="reference internal" href="../libraries/calendar.html">日历类</a></li>
<li class="toctree-l2"><a class="reference internal" href="../libraries/cart.html">购物车类</a></li>
<li class="toctree-l2"><a class="reference internal" href="../libraries/config.html">配置类</a></li>
<li class="toctree-l2"><a class="reference internal" href="../libraries/email.html">Email 类</a></li>
<li class="toctree-l2"><a class="reference internal" href="../libraries/encrypt.html">加密类</a></li>
<li class="toctree-l2"><a class="reference internal" href="../libraries/encryption.html">加密类（新版）</a></li>
<li class="toctree-l2"><a class="reference internal" href="../libraries/file_uploading.html">文件上传类</a></li>
<li class="toctree-l2"><a class="reference internal" href="../libraries/form_validation.html">表单验证类</a></li>
<li class="toctree-l2"><a class="reference internal" href="../libraries/ftp.html">FTP 类</a></li>
<li class="toctree-l2"><a class="reference internal" href="../libraries/image_lib.html">图像处理类</a></li>
<li class="toctree-l2"><a class="reference internal" href="../libraries/input.html">输入类</a></li>
<li class="toctree-l2"><a class="reference internal" href="../libraries/javascript.html">Javascript 类</a></li>
<li class="toctree-l2"><a class="reference internal" href="../libraries/language.html">语言类</a></li>
<li class="toctree-l2"><a class="reference internal" href="../libraries/loader.html">加载器类</a></li>
<li class="toctree-l2"><a class="reference internal" href="../libraries/migration.html">迁移类</a></li>
<li class="toctree-l2"><a class="reference internal" href="../libraries/output.html">输出类</a></li>
<li class="toctree-l2"><a class="reference internal" href="../libraries/pagination.html">分页类</a></li>
<li class="toctree-l2"><a class="reference internal" href="../libraries/parser.html">模板解析类</a></li>
<li class="toctree-l2"><a class="reference internal" href="../libraries/security.html">安全类</a></li>
<li class="toctree-l2"><a class="reference internal" href="../libraries/sessions.html">Session 类</a></li>
<li class="toctree-l2"><a class="reference internal" href="../libraries/table.html">HTML 表格类</a></li>
<li class="toctree-l2"><a class="reference internal" href="../libraries/trackback.html">引用通告类</a></li>
<li class="toctree-l2"><a class="reference internal" href="../libraries/typography.html">排版类</a></li>
<li class="toctree-l2"><a class="reference internal" href="../libraries/unit_testing.html">单元测试类</a></li>
<li class="toctree-l2"><a class="reference internal" href="../libraries/uri.html">URI 类</a></li>
<li class="toctree-l2"><a class="reference internal" href="../libraries/user_agent.html">用户代理类</a></li>
<li class="toctree-l2"><a class="reference internal" href="../libraries/xmlrpc.html">XML-RPC 与 XML-RPC 服务器类</a></li>
<li class="toctree-l2"><a class="reference internal" href="../libraries/zip.html">Zip 编码类</a></li>
</ul>
</li>
</ul>
<ul class="current">
<li class="toctree-l1 current"><a class="reference internal" href="index.html">数据库参考</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="examples.html">数据库快速入门: 示例代码</a></li>
<li class="toctree-l2"><a class="reference internal" href="configuration.html">数据库配置</a></li>
<li class="toctree-l2"><a class="reference internal" href="connecting.html">连接数据库</a></li>
<li class="toctree-l2"><a class="reference internal" href="queries.html">查询</a></li>
<li class="toctree-l2 current"><a class="current reference internal" href="">生成查询结果</a></li>
<li class="toctree-l2"><a class="reference internal" href="helpers.html">查询辅助函数</a></li>
<li class="toctree-l2"><a class="reference internal" href="query_builder.html">查询构造器类</a></li>
<li class="toctree-l2"><a class="reference internal" href="transactions.html">事务</a></li>
<li class="toctree-l2"><a class="reference internal" href="metadata.html">获取元数据</a></li>
<li class="toctree-l2"><a class="reference internal" href="call_function.html">自定义函数调用</a></li>
<li class="toctree-l2"><a class="reference internal" href="caching.html">查询缓存</a></li>
<li class="toctree-l2"><a class="reference internal" href="forge.html">使用 Database Forge 维护数据库</a></li>
<li class="toctree-l2"><a class="reference internal" href="utilities.html">数据库工具类</a></li>
<li class="toctree-l2"><a class="reference internal" href="db_driver_reference.html">数据库驱动器参考</a></li>
</ul>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../helpers/index.html">辅助函数参考</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../helpers/array_helper.html">数组辅助函数</a></li>
<li class="toctree-l2"><a class="reference internal" href="../helpers/captcha_helper.html">验证码辅助函数</a></li>
<li class="toctree-l2"><a class="reference internal" href="../helpers/cookie_helper.html">Cookie 辅助函数</a></li>
<li class="toctree-l2"><a class="reference internal" href="../helpers/date_helper.html">日期辅助函数</a></li>
<li class="toctree-l2"><a class="reference internal" href="../helpers/directory_helper.html">目录辅助函数</a></li>
<li class="toctree-l2"><a class="reference internal" href="../helpers/download_helper.html">下载辅助函数</a></li>
<li class="toctree-l2"><a class="reference internal" href="../helpers/email_helper.html">邮件辅助函数</a></li>
<li class="toctree-l2"><a class="reference internal" href="../helpers/file_helper.html">文件辅助函数</a></li>
<li class="toctree-l2"><a class="reference internal" href="../helpers/form_helper.html">表单辅助函数</a></li>
<li class="toctree-l2"><a class="reference internal" href="../helpers/html_helper.html">HTML 辅助函数</a></li>
<li class="toctree-l2"><a class="reference internal" href="../helpers/inflector_helper.html">Inflector 辅助函数</a></li>
<li class="toctree-l2"><a class="reference internal" href="../helpers/language_helper.html">语言辅助函数</a></li>
<li class="toctree-l2"><a class="reference internal" href="../helpers/number_helper.html">数字辅助函数</a></li>
<li class="toctree-l2"><a class="reference internal" href="../helpers/path_helper.html">路径辅助函数</a></li>
<li class="toctree-l2"><a class="reference internal" href="../helpers/security_helper.html">安全辅助函数</a></li>
<li class="toctree-l2"><a class="reference internal" href="../helpers/smiley_helper.html">表情辅助函数</a></li>
<li class="toctree-l2"><a class="reference internal" href="../helpers/string_helper.html">字符串辅助函数</a></li>
<li class="toctree-l2"><a class="reference internal" href="../helpers/text_helper.html">文本辅助函数</a></li>
<li class="toctree-l2"><a class="reference internal" href="../helpers/typography_helper.html">排版辅助函数</a></li>
<li class="toctree-l2"><a class="reference internal" href="../helpers/url_helper.html">URL 辅助函数</a></li>
<li class="toctree-l2"><a class="reference internal" href="../helpers/xml_helper.html">XML 辅助函数</a></li>
</ul>
</li>
</ul>

      </div>
    
      
  </div>
</div>
<div id="nav2">
  <a href="#" id="openToc">
    <img src="" title="切换目录" alt="切换目录" />
  </a>
</div>

  <div class="wy-grid-for-nav">

    
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-nav-search">
        
          <a href="../index.html" class="fa fa-home"> CodeIgniter</a>
        
        
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="../search.html" method="get">
    <input type="text" name="q" placeholder="搜索手册" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>
      </div>

      <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
        
          
          
              <ul>
<li class="toctree-l1"><a class="reference internal" href="../general/welcome.html">欢迎使用 CodeIgniter</a><ul class="simple">
</ul>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../installation/index.html">安装说明</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../installation/downloads.html">下载 CodeIgniter</a></li>
<li class="toctree-l2"><a class="reference internal" href="../installation/index.html">安装说明</a></li>
<li class="toctree-l2"><a class="reference internal" href="../installation/upgrading.html">从老版本升级</a></li>
<li class="toctree-l2"><a class="reference internal" href="../installation/troubleshooting.html">疑难解答</a></li>
</ul>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../overview/index.html">CodeIgniter 概览</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../overview/getting_started.html">开始</a></li>
<li class="toctree-l2"><a class="reference internal" href="../overview/at_a_glance.html">CodeIgniter 是什么？</a></li>
<li class="toctree-l2"><a class="reference internal" href="../overview/features.html">支持特性</a></li>
<li class="toctree-l2"><a class="reference internal" href="../overview/appflow.html">应用程序流程图</a></li>
<li class="toctree-l2"><a class="reference internal" href="../overview/mvc.html">模型 - 视图 - 控制器</a></li>
<li class="toctree-l2"><a class="reference internal" href="../overview/goals.html">架构目标</a></li>
</ul>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../tutorial/index.html">教程 - 内容提要</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../tutorial/static_pages.html">加载静态内容</a></li>
<li class="toctree-l2"><a class="reference internal" href="../tutorial/news_section.html">读取新闻条目</a></li>
<li class="toctree-l2"><a class="reference internal" href="../tutorial/create_news_items.html">创建新闻条目</a></li>
<li class="toctree-l2"><a class="reference internal" href="../tutorial/conclusion.html">结束语</a></li>
</ul>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../contributing/index.html">向 CodeIgniter 贡献你的力量</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../documentation/index.html">编写 CodeIgniter 的文档</a></li>
<li class="toctree-l2"><a class="reference internal" href="../DCO.html">Developer's Certificate of Origin 1.1</a></li>
</ul>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../general/index.html">常规主题</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../general/urls.html">CodeIgniter URL</a></li>
<li class="toctree-l2"><a class="reference internal" href="../general/controllers.html">控制器</a></li>
<li class="toctree-l2"><a class="reference internal" href="../general/reserved_names.html">保留名称</a></li>
<li class="toctree-l2"><a class="reference internal" href="../general/views.html">视图</a></li>
<li class="toctree-l2"><a class="reference internal" href="../general/models.html">模型</a></li>
<li class="toctree-l2"><a class="reference internal" href="../general/helpers.html">辅助函数</a></li>
<li class="toctree-l2"><a class="reference internal" href="../general/libraries.html">使用 CodeIgniter 类库</a></li>
<li class="toctree-l2"><a class="reference internal" href="../general/creating_libraries.html">创建类库</a></li>
<li class="toctree-l2"><a class="reference internal" href="../general/drivers.html">使用 CodeIgniter 驱动器</a></li>
<li class="toctree-l2"><a class="reference internal" href="../general/creating_drivers.html">创建驱动器</a></li>
<li class="toctree-l2"><a class="reference internal" href="../general/core_classes.html">创建核心系统类</a></li>
<li class="toctree-l2"><a class="reference internal" href="../general/ancillary_classes.html">创建附属类</a></li>
<li class="toctree-l2"><a class="reference internal" href="../general/hooks.html">钩子 - 扩展框架核心</a></li>
<li class="toctree-l2"><a class="reference internal" href="../general/autoloader.html">自动加载资源</a></li>
<li class="toctree-l2"><a class="reference internal" href="../general/common_functions.html">公共函数</a></li>
<li class="toctree-l2"><a class="reference internal" href="../general/compatibility_functions.html">兼容性函数</a></li>
<li class="toctree-l2"><a class="reference internal" href="../general/routing.html">URI 路由</a></li>
<li class="toctree-l2"><a class="reference internal" href="../general/errors.html">错误处理</a></li>
<li class="toctree-l2"><a class="reference internal" href="../general/caching.html">网页缓存</a></li>
<li class="toctree-l2"><a class="reference internal" href="../general/profiling.html">程序分析</a></li>
<li class="toctree-l2"><a class="reference internal" href="../general/cli.html">以 CLI 方式运行</a></li>
<li class="toctree-l2"><a class="reference internal" href="../general/managing_apps.html">管理你的应用程序</a></li>
<li class="toctree-l2"><a class="reference internal" href="../general/environments.html">处理多环境</a></li>
<li class="toctree-l2"><a class="reference internal" href="../general/alternative_php.html">在视图文件中使用 PHP 替代语法</a></li>
<li class="toctree-l2"><a class="reference internal" href="../general/security.html">安全</a></li>
<li class="toctree-l2"><a class="reference internal" href="../general/styleguide.html">PHP 开发规范</a></li>
</ul>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../libraries/index.html">类库参考</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../libraries/benchmark.html">基准测试类</a></li>
<li class="toctree-l2"><a class="reference internal" href="../libraries/caching.html">缓存驱动器</a></li>
<li class="toctree-l2"><a class="reference internal" href="../libraries/calendar.html">日历类</a></li>
<li class="toctree-l2"><a class="reference internal" href="../libraries/cart.html">购物车类</a></li>
<li class="toctree-l2"><a class="reference internal" href="../libraries/config.html">配置类</a></li>
<li class="toctree-l2"><a class="reference internal" href="../libraries/email.html">Email 类</a></li>
<li class="toctree-l2"><a class="reference internal" href="../libraries/encrypt.html">加密类</a></li>
<li class="toctree-l2"><a class="reference internal" href="../libraries/encryption.html">加密类（新版）</a></li>
<li class="toctree-l2"><a class="reference internal" href="../libraries/file_uploading.html">文件上传类</a></li>
<li class="toctree-l2"><a class="reference internal" href="../libraries/form_validation.html">表单验证类</a></li>
<li class="toctree-l2"><a class="reference internal" href="../libraries/ftp.html">FTP 类</a></li>
<li class="toctree-l2"><a class="reference internal" href="../libraries/image_lib.html">图像处理类</a></li>
<li class="toctree-l2"><a class="reference internal" href="../libraries/input.html">输入类</a></li>
<li class="toctree-l2"><a class="reference internal" href="../libraries/javascript.html">Javascript 类</a></li>
<li class="toctree-l2"><a class="reference internal" href="../libraries/language.html">语言类</a></li>
<li class="toctree-l2"><a class="reference internal" href="../libraries/loader.html">加载器类</a></li>
<li class="toctree-l2"><a class="reference internal" href="../libraries/migration.html">迁移类</a></li>
<li class="toctree-l2"><a class="reference internal" href="../libraries/output.html">输出类</a></li>
<li class="toctree-l2"><a class="reference internal" href="../libraries/pagination.html">分页类</a></li>
<li class="toctree-l2"><a class="reference internal" href="../libraries/parser.html">模板解析类</a></li>
<li class="toctree-l2"><a class="reference internal" href="../libraries/security.html">安全类</a></li>
<li class="toctree-l2"><a class="reference internal" href="../libraries/sessions.html">Session 类</a></li>
<li class="toctree-l2"><a class="reference internal" href="../libraries/table.html">HTML 表格类</a></li>
<li class="toctree-l2"><a class="reference internal" href="../libraries/trackback.html">引用通告类</a></li>
<li class="toctree-l2"><a class="reference internal" href="../libraries/typography.html">排版类</a></li>
<li class="toctree-l2"><a class="reference internal" href="../libraries/unit_testing.html">单元测试类</a></li>
<li class="toctree-l2"><a class="reference internal" href="../libraries/uri.html">URI 类</a></li>
<li class="toctree-l2"><a class="reference internal" href="../libraries/user_agent.html">用户代理类</a></li>
<li class="toctree-l2"><a class="reference internal" href="../libraries/xmlrpc.html">XML-RPC 与 XML-RPC 服务器类</a></li>
<li class="toctree-l2"><a class="reference internal" href="../libraries/zip.html">Zip 编码类</a></li>
</ul>
</li>
</ul>
<ul class="current">
<li class="toctree-l1 current"><a class="reference internal" href="index.html">数据库参考</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="examples.html">数据库快速入门: 示例代码</a></li>
<li class="toctree-l2"><a class="reference internal" href="configuration.html">数据库配置</a></li>
<li class="toctree-l2"><a class="reference internal" href="connecting.html">连接数据库</a></li>
<li class="toctree-l2"><a class="reference internal" href="queries.html">查询</a></li>
<li class="toctree-l2 current"><a class="current reference internal" href="">生成查询结果</a></li>
<li class="toctree-l2"><a class="reference internal" href="helpers.html">查询辅助函数</a></li>
<li class="toctree-l2"><a class="reference internal" href="query_builder.html">查询构造器类</a></li>
<li class="toctree-l2"><a class="reference internal" href="transactions.html">事务</a></li>
<li class="toctree-l2"><a class="reference internal" href="metadata.html">获取元数据</a></li>
<li class="toctree-l2"><a class="reference internal" href="call_function.html">自定义函数调用</a></li>
<li class="toctree-l2"><a class="reference internal" href="caching.html">查询缓存</a></li>
<li class="toctree-l2"><a class="reference internal" href="forge.html">使用 Database Forge 维护数据库</a></li>
<li class="toctree-l2"><a class="reference internal" href="utilities.html">数据库工具类</a></li>
<li class="toctree-l2"><a class="reference internal" href="db_driver_reference.html">数据库驱动器参考</a></li>
</ul>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../helpers/index.html">辅助函数参考</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../helpers/array_helper.html">数组辅助函数</a></li>
<li class="toctree-l2"><a class="reference internal" href="../helpers/captcha_helper.html">验证码辅助函数</a></li>
<li class="toctree-l2"><a class="reference internal" href="../helpers/cookie_helper.html">Cookie 辅助函数</a></li>
<li class="toctree-l2"><a class="reference internal" href="../helpers/date_helper.html">日期辅助函数</a></li>
<li class="toctree-l2"><a class="reference internal" href="../helpers/directory_helper.html">目录辅助函数</a></li>
<li class="toctree-l2"><a class="reference internal" href="../helpers/download_helper.html">下载辅助函数</a></li>
<li class="toctree-l2"><a class="reference internal" href="../helpers/email_helper.html">邮件辅助函数</a></li>
<li class="toctree-l2"><a class="reference internal" href="../helpers/file_helper.html">文件辅助函数</a></li>
<li class="toctree-l2"><a class="reference internal" href="../helpers/form_helper.html">表单辅助函数</a></li>
<li class="toctree-l2"><a class="reference internal" href="../helpers/html_helper.html">HTML 辅助函数</a></li>
<li class="toctree-l2"><a class="reference internal" href="../helpers/inflector_helper.html">Inflector 辅助函数</a></li>
<li class="toctree-l2"><a class="reference internal" href="../helpers/language_helper.html">语言辅助函数</a></li>
<li class="toctree-l2"><a class="reference internal" href="../helpers/number_helper.html">数字辅助函数</a></li>
<li class="toctree-l2"><a class="reference internal" href="../helpers/path_helper.html">路径辅助函数</a></li>
<li class="toctree-l2"><a class="reference internal" href="../helpers/security_helper.html">安全辅助函数</a></li>
<li class="toctree-l2"><a class="reference internal" href="../helpers/smiley_helper.html">表情辅助函数</a></li>
<li class="toctree-l2"><a class="reference internal" href="../helpers/string_helper.html">字符串辅助函数</a></li>
<li class="toctree-l2"><a class="reference internal" href="../helpers/text_helper.html">文本辅助函数</a></li>
<li class="toctree-l2"><a class="reference internal" href="../helpers/typography_helper.html">排版辅助函数</a></li>
<li class="toctree-l2"><a class="reference internal" href="../helpers/url_helper.html">URL 辅助函数</a></li>
<li class="toctree-l2"><a class="reference internal" href="../helpers/xml_helper.html">XML 辅助函数</a></li>
</ul>
</li>
</ul>

          
        
      </div>
      &nbsp;
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">

      
      <nav class="wy-nav-top" role="navigation" aria-label="top navigation">
        <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
        <a href="../index.html">CodeIgniter</a>
      </nav>


      
      <div class="wy-nav-content">
        <div class="rst-content">
          <div role="navigation" aria-label="breadcrumbs navigation">
  <ul class="wy-breadcrumbs">
    <li><a href="../index.html">首页</a> &raquo; </li>
    
    <li><a href="index.html">数据库参考</a> &raquo; </li>
    
    <li>生成查询结果</li>
    <li class="wy-breadcrumbs-aside">
      
    </li>
    <div style="float:right;">
      <div style="text-decoration:underline;color:blue;margin-left:5px;cursor:pointer;" id="closeMe">
        <img title="目录" alt="toc" src="" />
      </div>
    </div>
  </ul>
  <hr/>
</div>
          <div role="main" class="document">
            
  <div class="section" id="id1">
<h1>生成查询结果<a class="headerlink" href="#id1" title="永久链接至标题">¶</a></h1>
<p>有几种不同方法可以生成查询结果：</p>
<div class="contents local topic" id="contents">
<ul class="simple">
<li><a class="reference internal" href="#id2" id="id6">结果数组</a></li>
<li><a class="reference internal" href="#id3" id="id7">结果行</a></li>
<li><a class="reference internal" href="#id4" id="id8">自定义结果对象</a></li>
<li><a class="reference internal" href="#id5" id="id9">结果辅助方法</a></li>
<li><a class="reference internal" href="#class-reference" id="id10">Class Reference</a></li>
</ul>
</div>
<div class="section" id="id2">
<h2><a class="toc-backref" href="#id6">结果数组</a><a class="headerlink" href="#id2" title="永久链接至标题">¶</a></h2>
<p><strong>result()</strong> 方法</p>
<p>该方法以**对象数组**形式返回查询结果，如果查询失败返回**空数组**。
一般情况下，你会像下面这样在一个 foreach 循环中使用它:</p>
<div class="highlight-ci"><div class="highlight"><pre><span class="nv">$query</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">db</span><span class="o">-&gt;</span><span class="na">query</span><span class="p">(</span><span class="s2">&quot;YOUR QUERY&quot;</span><span class="p">);</span>

<span class="k">foreach</span> <span class="p">(</span><span class="nv">$query</span><span class="o">-&gt;</span><span class="na">result</span><span class="p">()</span> <span class="k">as</span> <span class="nv">$row</span><span class="p">)</span>
<span class="p">{</span>
    <span class="k">echo</span> <span class="nv">$row</span><span class="o">-&gt;</span><span class="na">title</span><span class="p">;</span>
    <span class="k">echo</span> <span class="nv">$row</span><span class="o">-&gt;</span><span class="na">name</span><span class="p">;</span>
    <span class="k">echo</span> <span class="nv">$row</span><span class="o">-&gt;</span><span class="na">body</span><span class="p">;</span>
<span class="p">}</span>
</pre></div>
</div>
<p>该方法是 <tt class="docutils literal"><span class="pre">result_object()</span></tt> 方法的别名。</p>
<p>你还可以传一个字符串参数给 <tt class="docutils literal"><span class="pre">result()</span></tt> 方法，这个字符串参数代表你想要把每个结果转换成某个类的类名（这个类必须已经加载）</p>
<div class="highlight-ci"><div class="highlight"><pre><span class="nv">$query</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">db</span><span class="o">-&gt;</span><span class="na">query</span><span class="p">(</span><span class="s2">&quot;SELECT * FROM users;&quot;</span><span class="p">);</span>

<span class="k">foreach</span> <span class="p">(</span><span class="nv">$query</span><span class="o">-&gt;</span><span class="na">result</span><span class="p">(</span><span class="s1">&#39;User&#39;</span><span class="p">)</span> <span class="k">as</span> <span class="nv">$user</span><span class="p">)</span>
<span class="p">{</span>
    <span class="k">echo</span> <span class="nv">$user</span><span class="o">-&gt;</span><span class="na">name</span><span class="p">;</span> <span class="c1">// access attributes</span>
    <span class="k">echo</span> <span class="nv">$user</span><span class="o">-&gt;</span><span class="na">reverse_name</span><span class="p">();</span> <span class="c1">// or methods defined on the &#39;User&#39; class</span>
<span class="p">}</span>
</pre></div>
</div>
<p><strong>result_array()</strong> 方法</p>
<p>这个方法以 <strong>一个纯粹的数组</strong> 形式返回查询结果，如果无结果，则返回一个空数组。一般情况下，你会像下面这样在一个 foreach 循环中使用它:</p>
<div class="highlight-ci"><div class="highlight"><pre><span class="nv">$query</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">db</span><span class="o">-&gt;</span><span class="na">query</span><span class="p">(</span><span class="s2">&quot;YOUR QUERY&quot;</span><span class="p">);</span>

<span class="k">foreach</span> <span class="p">(</span><span class="nv">$query</span><span class="o">-&gt;</span><span class="na">result_array</span><span class="p">()</span> <span class="k">as</span> <span class="nv">$row</span><span class="p">)</span>
<span class="p">{</span>
    <span class="k">echo</span> <span class="nv">$row</span><span class="p">[</span><span class="s1">&#39;title&#39;</span><span class="p">];</span>
    <span class="k">echo</span> <span class="nv">$row</span><span class="p">[</span><span class="s1">&#39;name&#39;</span><span class="p">];</span>
    <span class="k">echo</span> <span class="nv">$row</span><span class="p">[</span><span class="s1">&#39;body&#39;</span><span class="p">];</span>
<span class="p">}</span>
</pre></div>
</div>
</div>
<div class="section" id="id3">
<h2><a class="toc-backref" href="#id7">结果行</a><a class="headerlink" href="#id3" title="永久链接至标题">¶</a></h2>
<p><strong>row()</strong> 方法</p>
<p>这个方法返回单独一行结果。如果你的查询不止一行结果，它只返回第一行。返回的结果是 <strong>对象</strong> 形式，这里是用例:</p>
<div class="highlight-ci"><div class="highlight"><pre><span class="nv">$query</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">db</span><span class="o">-&gt;</span><span class="na">query</span><span class="p">(</span><span class="s2">&quot;YOUR QUERY&quot;</span><span class="p">);</span>

<span class="nv">$row</span> <span class="o">=</span> <span class="nv">$query</span><span class="o">-&gt;</span><span class="na">row</span><span class="p">();</span>

<span class="k">if</span> <span class="p">(</span><span class="nb">isset</span><span class="p">(</span><span class="nv">$row</span><span class="p">))</span>
<span class="p">{</span>
    <span class="k">echo</span> <span class="nv">$row</span><span class="o">-&gt;</span><span class="na">title</span><span class="p">;</span>
    <span class="k">echo</span> <span class="nv">$row</span><span class="o">-&gt;</span><span class="na">name</span><span class="p">;</span>
    <span class="k">echo</span> <span class="nv">$row</span><span class="o">-&gt;</span><span class="na">body</span><span class="p">;</span>
<span class="p">}</span>
</pre></div>
</div>
<p>如果你要返回特定行的数据，你可以将行号作为第一个参数传给这个方法:</p>
<div class="highlight-ci"><div class="highlight"><pre><span class="nv">$row</span> <span class="o">=</span> <span class="nv">$query</span><span class="o">-&gt;</span><span class="na">row</span><span class="p">(</span><span class="mi">5</span><span class="p">);</span>
</pre></div>
</div>
<p>你还可以加上第二个参数，该参数为字符串类型，代表你想要把结果转换成某个类的类名:</p>
<div class="highlight-ci"><div class="highlight"><pre><span class="nv">$query</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">db</span><span class="o">-&gt;</span><span class="na">query</span><span class="p">(</span><span class="s2">&quot;SELECT * FROM users LIMIT 1;&quot;</span><span class="p">);</span>
<span class="nv">$row</span> <span class="o">=</span> <span class="nv">$query</span><span class="o">-&gt;</span><span class="na">row</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="s1">&#39;User&#39;</span><span class="p">);</span>

<span class="k">echo</span> <span class="nv">$row</span><span class="o">-&gt;</span><span class="na">name</span><span class="p">;</span> <span class="c1">// access attributes</span>
<span class="k">echo</span> <span class="nv">$row</span><span class="o">-&gt;</span><span class="na">reverse_name</span><span class="p">();</span> <span class="c1">// or methods defined on the &#39;User&#39; class</span>
</pre></div>
</div>
<p><strong>row_array()</strong> 方法</p>
<p>这个方法除了返回结果是一个数组而不是一个对象之外，其他的和上面的 <tt class="docutils literal"><span class="pre">row()</span></tt> 方法完全一样。举例:</p>
<div class="highlight-ci"><div class="highlight"><pre><span class="nv">$query</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">db</span><span class="o">-&gt;</span><span class="na">query</span><span class="p">(</span><span class="s2">&quot;YOUR QUERY&quot;</span><span class="p">);</span>

<span class="nv">$row</span> <span class="o">=</span> <span class="nv">$query</span><span class="o">-&gt;</span><span class="na">row_array</span><span class="p">();</span>

<span class="k">if</span> <span class="p">(</span><span class="nb">isset</span><span class="p">(</span><span class="nv">$row</span><span class="p">))</span>
<span class="p">{</span>
    <span class="k">echo</span> <span class="nv">$row</span><span class="p">[</span><span class="s1">&#39;title&#39;</span><span class="p">];</span>
    <span class="k">echo</span> <span class="nv">$row</span><span class="p">[</span><span class="s1">&#39;name&#39;</span><span class="p">];</span>
    <span class="k">echo</span> <span class="nv">$row</span><span class="p">[</span><span class="s1">&#39;body&#39;</span><span class="p">];</span>
<span class="p">}</span>
</pre></div>
</div>
<p>如果你要返回特定行的数据，你可以将行号作为第一个参数传给这个方法:</p>
<div class="highlight-ci"><div class="highlight"><pre><span class="nv">$row</span> <span class="o">=</span> <span class="nv">$query</span><span class="o">-&gt;</span><span class="na">row_array</span><span class="p">(</span><span class="mi">5</span><span class="p">);</span>
</pre></div>
</div>
<p>另外，你可以使用下面这些方法从你的结果集中获取前一个、后一个、
第一个或者最后一个结果：</p>
<blockquote>
<div><div class="line-block">
<div class="line"><strong>$row = $query-&gt;first_row()</strong></div>
<div class="line"><strong>$row = $query-&gt;last_row()</strong></div>
<div class="line"><strong>$row = $query-&gt;next_row()</strong></div>
<div class="line"><strong>$row = $query-&gt;previous_row()</strong></div>
</div>
</div></blockquote>
<p>这些方法默认返回对象，如果需要返回数组形式，将单词 &quot;array&quot; 作为参数传入方法即可：</p>
<blockquote>
<div><div class="line-block">
<div class="line"><strong>$row = $query-&gt;first_row('array')</strong></div>
<div class="line"><strong>$row = $query-&gt;last_row('array')</strong></div>
<div class="line"><strong>$row = $query-&gt;next_row('array')</strong></div>
<div class="line"><strong>$row = $query-&gt;previous_row('array')</strong></div>
</div>
</div></blockquote>
<div class="admonition note">
<p class="first admonition-title">注解</p>
<p class="last">上面所有的这些方法都会把所有的结果加载到内存里（预读取），
当处理大结果集时最好使用 <tt class="docutils literal"><span class="pre">unbuffered_row()</span></tt> 方法。</p>
</div>
<p><strong>unbuffered_row()</strong> 方法</p>
<p>这个方法和 <tt class="docutils literal"><span class="pre">row()</span></tt> 方法一样返回单独一行结果，但是它不会预读取所有的结果数据到内存中。
如果你的查询结果不止一行，它将返回当前一行，并通过内部实现的指针来移动到下一行。</p>
<div class="highlight-ci"><div class="highlight"><pre><span class="nv">$query</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">db</span><span class="o">-&gt;</span><span class="na">query</span><span class="p">(</span><span class="s2">&quot;YOUR QUERY&quot;</span><span class="p">);</span>

<span class="k">while</span> <span class="p">(</span><span class="nv">$row</span> <span class="o">=</span> <span class="nv">$query</span><span class="o">-&gt;</span><span class="na">unbuffered_row</span><span class="p">())</span>
<span class="p">{</span>
    <span class="k">echo</span> <span class="nv">$row</span><span class="o">-&gt;</span><span class="na">title</span><span class="p">;</span>
    <span class="k">echo</span> <span class="nv">$row</span><span class="o">-&gt;</span><span class="na">name</span><span class="p">;</span>
    <span class="k">echo</span> <span class="nv">$row</span><span class="o">-&gt;</span><span class="na">body</span><span class="p">;</span>
<span class="p">}</span>
</pre></div>
</div>
<p>为了指定返回值的类型，可以传一个字符串参数 'object'（默认值） 或者 'array' 给这个方法:</p>
<div class="highlight-ci"><div class="highlight"><pre><span class="nv">$query</span><span class="o">-&gt;</span><span class="na">unbuffered_row</span><span class="p">();</span>       <span class="c1">// object</span>
<span class="nv">$query</span><span class="o">-&gt;</span><span class="na">unbuffered_row</span><span class="p">(</span><span class="s1">&#39;object&#39;</span><span class="p">);</span>   <span class="c1">// object</span>
<span class="nv">$query</span><span class="o">-&gt;</span><span class="na">unbuffered_row</span><span class="p">(</span><span class="s1">&#39;array&#39;</span><span class="p">);</span>    <span class="c1">// associative array</span>
</pre></div>
</div>
</div>
<div class="section" id="id4">
<h2><a class="toc-backref" href="#id8">自定义结果对象</a><a class="headerlink" href="#id4" title="永久链接至标题">¶</a></h2>
<p>You can have the results returned as an instance of a custom class instead
of a <tt class="docutils literal"><span class="pre">stdClass</span></tt> or array, as the <tt class="docutils literal"><span class="pre">result()</span></tt> and <tt class="docutils literal"><span class="pre">result_array()</span></tt>
methods allow. This requires that the class is already loaded into memory.
The object will have all values returned from the database set as properties.
If these have been declared and are non-public then you should provide a
<tt class="docutils literal"><span class="pre">__set()</span></tt> method to allow them to be set.</p>
<p>Example:</p>
<div class="highlight-ci"><div class="highlight"><pre><span class="k">class</span> <span class="nc">User</span> <span class="p">{</span>

    <span class="k">public</span> <span class="nv">$id</span><span class="p">;</span>
    <span class="k">public</span> <span class="nv">$email</span><span class="p">;</span>
    <span class="k">public</span> <span class="nv">$username</span><span class="p">;</span>

    <span class="k">protected</span> <span class="nv">$last_login</span><span class="p">;</span>

    <span class="k">public</span> <span class="k">function</span> <span class="nf">last_login</span><span class="p">(</span><span class="nv">$format</span><span class="p">)</span>
    <span class="p">{</span>
        <span class="k">return</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">last_login</span><span class="o">-&gt;</span><span class="na">format</span><span class="p">(</span><span class="nv">$format</span><span class="p">);</span>
    <span class="p">}</span>

    <span class="k">public</span> <span class="k">function</span> <span class="nf">__set</span><span class="p">(</span><span class="nv">$name</span><span class="p">,</span> <span class="nv">$value</span><span class="p">)</span>
    <span class="p">{</span>
        <span class="k">if</span> <span class="p">(</span><span class="nv">$name</span> <span class="o">===</span> <span class="s1">&#39;last_login&#39;</span><span class="p">)</span>
        <span class="p">{</span>
            <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">last_login</span> <span class="o">=</span> <span class="nx">DateTime</span><span class="o">::</span><span class="na">createFromFormat</span><span class="p">(</span><span class="s1">&#39;U&#39;</span><span class="p">,</span> <span class="nv">$value</span><span class="p">);</span>
        <span class="p">}</span>
    <span class="p">}</span>

    <span class="k">public</span> <span class="k">function</span> <span class="nf">__get</span><span class="p">(</span><span class="nv">$name</span><span class="p">)</span>
    <span class="p">{</span>
        <span class="k">if</span> <span class="p">(</span><span class="nb">isset</span><span class="p">(</span><span class="nv">$this</span><span class="o">-&gt;</span><span class="nv">$name</span><span class="p">))</span>
        <span class="p">{</span>
            <span class="k">return</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="nv">$name</span><span class="p">;</span>
        <span class="p">}</span>
    <span class="p">}</span>
<span class="p">}</span>
</pre></div>
</div>
<p>In addition to the two methods listed below, the following methods also can
take a class name to return the results as: <tt class="docutils literal"><span class="pre">first_row()</span></tt>, <tt class="docutils literal"><span class="pre">last_row()</span></tt>,
<tt class="docutils literal"><span class="pre">next_row()</span></tt>, and <tt class="docutils literal"><span class="pre">previous_row()</span></tt>.</p>
<p><strong>custom_result_object()</strong></p>
<p>Returns the entire result set as an array of instances of the class requested.
The only parameter is the name of the class to instantiate.</p>
<p>Example:</p>
<div class="highlight-ci"><div class="highlight"><pre><span class="nv">$query</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">db</span><span class="o">-&gt;</span><span class="na">query</span><span class="p">(</span><span class="s2">&quot;YOUR QUERY&quot;</span><span class="p">);</span>

<span class="nv">$rows</span> <span class="o">=</span> <span class="nv">$query</span><span class="o">-&gt;</span><span class="na">custom_result_object</span><span class="p">(</span><span class="s1">&#39;User&#39;</span><span class="p">);</span>

<span class="k">foreach</span> <span class="p">(</span><span class="nv">$rows</span> <span class="k">as</span> <span class="nv">$row</span><span class="p">)</span>
<span class="p">{</span>
    <span class="k">echo</span> <span class="nv">$row</span><span class="o">-&gt;</span><span class="na">id</span><span class="p">;</span>
    <span class="k">echo</span> <span class="nv">$row</span><span class="o">-&gt;</span><span class="na">email</span><span class="p">;</span>
    <span class="k">echo</span> <span class="nv">$row</span><span class="o">-&gt;</span><span class="na">last_login</span><span class="p">(</span><span class="s1">&#39;Y-m-d&#39;</span><span class="p">);</span>
<span class="p">}</span>
</pre></div>
</div>
<p><strong>custom_row_object()</strong></p>
<p>Returns a single row from your query results. The first parameter is the row
number of the results. The second parameter is the class name to instantiate.</p>
<p>Example:</p>
<div class="highlight-ci"><div class="highlight"><pre><span class="nv">$query</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">db</span><span class="o">-&gt;</span><span class="na">query</span><span class="p">(</span><span class="s2">&quot;YOUR QUERY&quot;</span><span class="p">);</span>

<span class="nv">$row</span> <span class="o">=</span> <span class="nv">$query</span><span class="o">-&gt;</span><span class="na">custom_row_object</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="s1">&#39;User&#39;</span><span class="p">);</span>

<span class="k">if</span> <span class="p">(</span><span class="nb">isset</span><span class="p">(</span><span class="nv">$row</span><span class="p">))</span>
<span class="p">{</span>
    <span class="k">echo</span> <span class="nv">$row</span><span class="o">-&gt;</span><span class="na">email</span><span class="p">;</span>   <span class="c1">// access attributes</span>
    <span class="k">echo</span> <span class="nv">$row</span><span class="o">-&gt;</span><span class="na">last_login</span><span class="p">(</span><span class="s1">&#39;Y-m-d&#39;</span><span class="p">);</span>   <span class="c1">// access class methods</span>
<span class="p">}</span>
</pre></div>
</div>
<p>You can also use the <tt class="docutils literal"><span class="pre">row()</span></tt> method in exactly the same way.</p>
<p>Example:</p>
<div class="highlight-ci"><div class="highlight"><pre><span class="nv">$row</span> <span class="o">=</span> <span class="nv">$query</span><span class="o">-&gt;</span><span class="na">custom_row_object</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="s1">&#39;User&#39;</span><span class="p">);</span>
</pre></div>
</div>
</div>
<div class="section" id="id5">
<h2><a class="toc-backref" href="#id9">结果辅助方法</a><a class="headerlink" href="#id5" title="永久链接至标题">¶</a></h2>
<p><strong>num_rows()</strong> 方法</p>
<p>该方法返回查询结果的行数。注意：在这个例子中，<tt class="docutils literal"><span class="pre">$query</span></tt> 变量为查询结果对象:</p>
<div class="highlight-ci"><div class="highlight"><pre><span class="nv">$query</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">db</span><span class="o">-&gt;</span><span class="na">query</span><span class="p">(</span><span class="s1">&#39;SELECT * FROM my_table&#39;</span><span class="p">);</span>

<span class="k">echo</span> <span class="nv">$query</span><span class="o">-&gt;</span><span class="na">num_rows</span><span class="p">();</span>
</pre></div>
</div>
<div class="admonition note">
<p class="first admonition-title">注解</p>
<p class="last">并不是所有的数据库驱动器都有原生的方法来获取查询结果的总行数。
当遇到这种情况时，所有的数据会被预读取到内存中，并调用 <tt class="docutils literal"><span class="pre">count()</span></tt> 函数
来取得总行数。</p>
</div>
<p><strong>num_fields()</strong> 方法</p>
<p>该方法返回查询结果的字段数（列数）。在你的查询结果对象上调用该方法:</p>
<div class="highlight-ci"><div class="highlight"><pre><span class="nv">$query</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">db</span><span class="o">-&gt;</span><span class="na">query</span><span class="p">(</span><span class="s1">&#39;SELECT * FROM my_table&#39;</span><span class="p">);</span>

<span class="k">echo</span> <span class="nv">$query</span><span class="o">-&gt;</span><span class="na">num_fields</span><span class="p">();</span>
</pre></div>
</div>
<p><strong>free_result()</strong> 方法</p>
<p>该方法释放掉查询结果所占的内存，并删除结果的资源标识。通常来说，
PHP 会在脚本执行结束后自动释放内存。但是，如果你在某个脚本中执行大量的查询，
你可能需要在每次查询之后释放掉查询结果，以此来降低内存消耗。</p>
<p>举例:</p>
<div class="highlight-ci"><div class="highlight"><pre><span class="nv">$query</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">db</span><span class="o">-&gt;</span><span class="na">query</span><span class="p">(</span><span class="s1">&#39;SELECT title FROM my_table&#39;</span><span class="p">);</span>

<span class="k">foreach</span> <span class="p">(</span><span class="nv">$query</span><span class="o">-&gt;</span><span class="na">result</span><span class="p">()</span> <span class="k">as</span> <span class="nv">$row</span><span class="p">)</span>
<span class="p">{</span>
    <span class="k">echo</span> <span class="nv">$row</span><span class="o">-&gt;</span><span class="na">title</span><span class="p">;</span>
<span class="p">}</span>

<span class="nv">$query</span><span class="o">-&gt;</span><span class="na">free_result</span><span class="p">();</span>  <span class="c1">// The $query result object will no longer be available</span>

<span class="nv">$query2</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">db</span><span class="o">-&gt;</span><span class="na">query</span><span class="p">(</span><span class="s1">&#39;SELECT name FROM some_table&#39;</span><span class="p">);</span>

<span class="nv">$row</span> <span class="o">=</span> <span class="nv">$query2</span><span class="o">-&gt;</span><span class="na">row</span><span class="p">();</span>
<span class="k">echo</span> <span class="nv">$row</span><span class="o">-&gt;</span><span class="na">name</span><span class="p">;</span>
<span class="nv">$query2</span><span class="o">-&gt;</span><span class="na">free_result</span><span class="p">();</span> <span class="c1">// The $query2 result object will no longer be available</span>
</pre></div>
</div>
<p><strong>data_seek()</strong> 方法</p>
<p>这个方法用来设置下一个结果行的内部指针，它只有在和 <tt class="docutils literal"><span class="pre">unbuffered_row()</span></tt> 方法一起使用才有效果。</p>
<p>它接受一个正整数参数（默认值为0）表示想要读取的下一行，返回值为 TRUE 或 FALSE 表示成功或失败。</p>
<div class="highlight-ci"><div class="highlight"><pre><span class="nv">$query</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">db</span><span class="o">-&gt;</span><span class="na">query</span><span class="p">(</span><span class="s1">&#39;SELECT `field_name` FROM `table_name`&#39;</span><span class="p">);</span>
<span class="nv">$query</span><span class="o">-&gt;</span><span class="na">data_seek</span><span class="p">(</span><span class="mi">5</span><span class="p">);</span> <span class="c1">// Skip the first 5 rows</span>
<span class="nv">$row</span> <span class="o">=</span> <span class="nv">$query</span><span class="o">-&gt;</span><span class="na">unbuffered_row</span><span class="p">();</span>
</pre></div>
</div>
<div class="admonition note">
<p class="first admonition-title">注解</p>
<p class="last">并不是所有的数据库驱动器都支持这一特性，调用这个方法将会返回 FALSE，
例如你无法在 PDO 上使用它。</p>
</div>
</div>
<div class="section" id="class-reference">
<h2><a class="toc-backref" href="#id10">Class Reference</a><a class="headerlink" href="#class-reference" title="永久链接至标题">¶</a></h2>
<dl class="class">
<dt id="CI_DB_result">
<em class="property">class </em><tt class="descname">CI_DB_result</tt><a class="headerlink" href="#CI_DB_result" title="永久链接至目标">¶</a></dt>
<dd><dl class="method">
<dt id="CI_DB_result::result">
<tt class="descname">result</tt><big>(</big><span class="optional">[</span><em>$type = 'object'</em><span class="optional">]</span><big>)</big><a class="headerlink" href="#CI_DB_result::result" title="永久链接至目标">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">参数:</th><td class="field-body"><ul class="first simple">
<li><strong>$type</strong> (<em>string</em>) -- Type of requested results - array, object, or class name</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">返回:</th><td class="field-body"><p class="first">Array containing the fetched rows</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">返回类型:</th><td class="field-body"><p class="first last">array</p>
</td>
</tr>
</tbody>
</table>
<p>A wrapper for the <tt class="docutils literal"><span class="pre">result_array()</span></tt>, <tt class="docutils literal"><span class="pre">result_object()</span></tt>
and <tt class="docutils literal"><span class="pre">custom_result_object()</span></tt> methods.</p>
<p>Usage: see <a class="reference internal" href="#id2">结果数组</a>.</p>
</dd></dl>

<dl class="method">
<dt id="CI_DB_result::result_array">
<tt class="descname">result_array</tt><big>(</big><big>)</big><a class="headerlink" href="#CI_DB_result::result_array" title="永久链接至目标">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">返回:</th><td class="field-body">Array containing the fetched rows</td>
</tr>
<tr class="field-even field"><th class="field-name">返回类型:</th><td class="field-body">array</td>
</tr>
</tbody>
</table>
<p>Returns the query results as an array of rows, where each
row is itself an associative array.</p>
<p>Usage: see <a class="reference internal" href="#id2">结果数组</a>.</p>
</dd></dl>

<dl class="method">
<dt id="CI_DB_result::result_object">
<tt class="descname">result_object</tt><big>(</big><big>)</big><a class="headerlink" href="#CI_DB_result::result_object" title="永久链接至目标">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">返回:</th><td class="field-body">Array containing the fetched rows</td>
</tr>
<tr class="field-even field"><th class="field-name">返回类型:</th><td class="field-body">array</td>
</tr>
</tbody>
</table>
<p>Returns the query results as an array of rows, where each
row is an object of type <tt class="docutils literal"><span class="pre">stdClass</span></tt>.</p>
<p>Usage: see <a class="reference internal" href="#id2">结果数组</a>.</p>
</dd></dl>

<dl class="method">
<dt id="CI_DB_result::custom_result_object">
<tt class="descname">custom_result_object</tt><big>(</big><em>$class_name</em><big>)</big><a class="headerlink" href="#CI_DB_result::custom_result_object" title="永久链接至目标">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">参数:</th><td class="field-body"><ul class="first simple">
<li><strong>$class_name</strong> (<em>string</em>) -- Class name for the resulting rows</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">返回:</th><td class="field-body"><p class="first">Array containing the fetched rows</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">返回类型:</th><td class="field-body"><p class="first last">array</p>
</td>
</tr>
</tbody>
</table>
<p>Returns the query results as an array of rows, where each
row is an instance of the specified class.</p>
</dd></dl>

<dl class="method">
<dt id="CI_DB_result::row">
<tt class="descname">row</tt><big>(</big><span class="optional">[</span><em>$n = 0</em><span class="optional">[</span>, <em>$type = 'object'</em><span class="optional">]</span><span class="optional">]</span><big>)</big><a class="headerlink" href="#CI_DB_result::row" title="永久链接至目标">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">参数:</th><td class="field-body"><ul class="first simple">
<li><strong>$n</strong> (<em>int</em>) -- Index of the query results row to be returned</li>
<li><strong>$type</strong> (<em>string</em>) -- Type of the requested result - array, object, or class name</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">返回:</th><td class="field-body"><p class="first">The requested row or NULL if it doesn't exist</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">返回类型:</th><td class="field-body"><p class="first last">mixed</p>
</td>
</tr>
</tbody>
</table>
<p>A wrapper for the <tt class="docutils literal"><span class="pre">row_array()</span></tt>, <tt class="docutils literal"><span class="pre">row_object()</span> <span class="pre">and</span>
<span class="pre">``custom_row_object()</span></tt> methods.</p>
<p>Usage: see <a class="reference internal" href="#id3">结果行</a>.</p>
</dd></dl>

<dl class="method">
<dt id="CI_DB_result::unbuffered_row">
<tt class="descname">unbuffered_row</tt><big>(</big><span class="optional">[</span><em>$type = 'object'</em><span class="optional">]</span><big>)</big><a class="headerlink" href="#CI_DB_result::unbuffered_row" title="永久链接至目标">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">参数:</th><td class="field-body"><ul class="first simple">
<li><strong>$type</strong> (<em>string</em>) -- Type of the requested result - array, object, or class name</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">返回:</th><td class="field-body"><p class="first">Next row from the result set or NULL if it doesn't exist</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">返回类型:</th><td class="field-body"><p class="first last">mixed</p>
</td>
</tr>
</tbody>
</table>
<p>Fetches the next result row and returns it in the
requested form.</p>
<p>Usage: see <a class="reference internal" href="#id3">结果行</a>.</p>
</dd></dl>

<dl class="method">
<dt id="CI_DB_result::row_array">
<tt class="descname">row_array</tt><big>(</big><span class="optional">[</span><em>$n = 0</em><span class="optional">]</span><big>)</big><a class="headerlink" href="#CI_DB_result::row_array" title="永久链接至目标">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">参数:</th><td class="field-body"><ul class="first simple">
<li><strong>$n</strong> (<em>int</em>) -- Index of the query results row to be returned</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">返回:</th><td class="field-body"><p class="first">The requested row or NULL if it doesn't exist</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">返回类型:</th><td class="field-body"><p class="first last">array</p>
</td>
</tr>
</tbody>
</table>
<p>Returns the requested result row as an associative array.</p>
<p>Usage: see <a class="reference internal" href="#id3">结果行</a>.</p>
</dd></dl>

<dl class="method">
<dt id="CI_DB_result::row_object">
<tt class="descname">row_object</tt><big>(</big><span class="optional">[</span><em>$n = 0</em><span class="optional">]</span><big>)</big><a class="headerlink" href="#CI_DB_result::row_object" title="永久链接至目标">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">参数:</th><td class="field-body"><ul class="first simple">
<li><strong>$n</strong> (<em>int</em>) -- Index of the query results row to be returned
:returns:   The requested row or NULL if it doesn't exist</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">返回类型:</th><td class="field-body"><p class="first last">stdClass</p>
</td>
</tr>
</tbody>
</table>
<p>Returns the requested result row as an object of type
<tt class="docutils literal"><span class="pre">stdClass</span></tt>.</p>
<p>Usage: see <a class="reference internal" href="#id3">结果行</a>.</p>
</dd></dl>

<dl class="method">
<dt id="CI_DB_result::custom_row_object">
<tt class="descname">custom_row_object</tt><big>(</big><em>$n</em>, <em>$type</em><big>)</big><a class="headerlink" href="#CI_DB_result::custom_row_object" title="永久链接至目标">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">参数:</th><td class="field-body"><ul class="first simple">
<li><strong>$n</strong> (<em>int</em>) -- Index of the results row to return</li>
<li><strong>$class_name</strong> (<em>string</em>) -- Class name for the resulting row</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">返回:</th><td class="field-body"><p class="first">The requested row or NULL if it doesn't exist</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">返回类型:</th><td class="field-body"><p class="first last">$type</p>
</td>
</tr>
</tbody>
</table>
<p>Returns the requested result row as an instance of the
requested class.</p>
</dd></dl>

<dl class="method">
<dt id="CI_DB_result::data_seek">
<tt class="descname">data_seek</tt><big>(</big><span class="optional">[</span><em>$n = 0</em><span class="optional">]</span><big>)</big><a class="headerlink" href="#CI_DB_result::data_seek" title="永久链接至目标">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">参数:</th><td class="field-body"><ul class="first simple">
<li><strong>$n</strong> (<em>int</em>) -- Index of the results row to be returned next</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">返回:</th><td class="field-body"><p class="first">TRUE on success, FALSE on failure</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">返回类型:</th><td class="field-body"><p class="first last">bool</p>
</td>
</tr>
</tbody>
</table>
<p>Moves the internal results row pointer to the desired offset.</p>
<p>Usage: see <a class="reference internal" href="#id5">结果辅助方法</a>.</p>
</dd></dl>

<dl class="method">
<dt id="CI_DB_result::set_row">
<tt class="descname">set_row</tt><big>(</big><em>$key</em><span class="optional">[</span>, <em>$value = NULL</em><span class="optional">]</span><big>)</big><a class="headerlink" href="#CI_DB_result::set_row" title="永久链接至目标">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">参数:</th><td class="field-body"><ul class="first simple">
<li><strong>$key</strong> (<em>mixed</em>) -- Column name or array of key/value pairs</li>
<li><strong>$value</strong> (<em>mixed</em>) -- Value to assign to the column, $key is a single field name</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">返回类型:</th><td class="field-body"><p class="first last">void</p>
</td>
</tr>
</tbody>
</table>
<p>Assigns a value to a particular column.</p>
</dd></dl>

<dl class="method">
<dt id="CI_DB_result::next_row">
<tt class="descname">next_row</tt><big>(</big><span class="optional">[</span><em>$type = 'object'</em><span class="optional">]</span><big>)</big><a class="headerlink" href="#CI_DB_result::next_row" title="永久链接至目标">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">参数:</th><td class="field-body"><ul class="first simple">
<li><strong>$type</strong> (<em>string</em>) -- Type of the requested result - array, object, or class name</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">返回:</th><td class="field-body"><p class="first">Next row of result set, or NULL if it doesn't exist</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">返回类型:</th><td class="field-body"><p class="first last">mixed</p>
</td>
</tr>
</tbody>
</table>
<p>Returns the next row from the result set.</p>
</dd></dl>

<dl class="method">
<dt id="CI_DB_result::previous_row">
<tt class="descname">previous_row</tt><big>(</big><span class="optional">[</span><em>$type = 'object'</em><span class="optional">]</span><big>)</big><a class="headerlink" href="#CI_DB_result::previous_row" title="永久链接至目标">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">参数:</th><td class="field-body"><ul class="first simple">
<li><strong>$type</strong> (<em>string</em>) -- Type of the requested result - array, object, or class name</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">返回:</th><td class="field-body"><p class="first">Previous row of result set, or NULL if it doesn't exist</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">返回类型:</th><td class="field-body"><p class="first last">mixed</p>
</td>
</tr>
</tbody>
</table>
<p>Returns the previous row from the result set.</p>
</dd></dl>

<dl class="method">
<dt id="CI_DB_result::first_row">
<tt class="descname">first_row</tt><big>(</big><span class="optional">[</span><em>$type = 'object'</em><span class="optional">]</span><big>)</big><a class="headerlink" href="#CI_DB_result::first_row" title="永久链接至目标">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">参数:</th><td class="field-body"><ul class="first simple">
<li><strong>$type</strong> (<em>string</em>) -- Type of the requested result - array, object, or class name</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">返回:</th><td class="field-body"><p class="first">First row of result set, or NULL if it doesn't exist</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">返回类型:</th><td class="field-body"><p class="first last">mixed</p>
</td>
</tr>
</tbody>
</table>
<p>Returns the first row from the result set.</p>
</dd></dl>

<dl class="method">
<dt id="CI_DB_result::last_row">
<tt class="descname">last_row</tt><big>(</big><span class="optional">[</span><em>$type = 'object'</em><span class="optional">]</span><big>)</big><a class="headerlink" href="#CI_DB_result::last_row" title="永久链接至目标">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">参数:</th><td class="field-body"><ul class="first simple">
<li><strong>$type</strong> (<em>string</em>) -- Type of the requested result - array, object, or class name</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">返回:</th><td class="field-body"><p class="first">Last row of result set, or NULL if it doesn't exist</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">返回类型:</th><td class="field-body"><p class="first last">mixed</p>
</td>
</tr>
</tbody>
</table>
<p>Returns the last row from the result set.</p>
</dd></dl>

<dl class="method">
<dt id="CI_DB_result::num_rows">
<tt class="descname">num_rows</tt><big>(</big><big>)</big><a class="headerlink" href="#CI_DB_result::num_rows" title="永久链接至目标">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">返回:</th><td class="field-body">Number of rows in the result set</td>
</tr>
<tr class="field-even field"><th class="field-name">返回类型:</th><td class="field-body">int</td>
</tr>
</tbody>
</table>
<p>Returns the number of rows in the result set.</p>
<p>Usage: see <a class="reference internal" href="#id5">结果辅助方法</a>.</p>
</dd></dl>

<dl class="method">
<dt id="CI_DB_result::num_fields">
<tt class="descname">num_fields</tt><big>(</big><big>)</big><a class="headerlink" href="#CI_DB_result::num_fields" title="永久链接至目标">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">返回:</th><td class="field-body">Number of fields in the result set</td>
</tr>
<tr class="field-even field"><th class="field-name">返回类型:</th><td class="field-body">int</td>
</tr>
</tbody>
</table>
<p>Returns the number of fields in the result set.</p>
<p>Usage: see <a class="reference internal" href="#id5">结果辅助方法</a>.</p>
</dd></dl>

<dl class="method">
<dt id="CI_DB_result::field_data">
<tt class="descname">field_data</tt><big>(</big><big>)</big><a class="headerlink" href="#CI_DB_result::field_data" title="永久链接至目标">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">返回:</th><td class="field-body">Array containing field meta-data</td>
</tr>
<tr class="field-even field"><th class="field-name">返回类型:</th><td class="field-body">array</td>
</tr>
</tbody>
</table>
<p>Generates an array of <tt class="docutils literal"><span class="pre">stdClass</span></tt> objects containing
field meta-data.</p>
</dd></dl>

<dl class="method">
<dt id="CI_DB_result::free_result">
<tt class="descname">free_result</tt><big>(</big><big>)</big><a class="headerlink" href="#CI_DB_result::free_result" title="永久链接至目标">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">返回类型:</th><td class="field-body">void</td>
</tr>
</tbody>
</table>
<p>Frees a result set.</p>
<p>Usage: see <a class="reference internal" href="#id5">结果辅助方法</a>.</p>
</dd></dl>

<dl class="method">
<dt id="CI_DB_result::list_fields">
<tt class="descname">list_fields</tt><big>(</big><big>)</big><a class="headerlink" href="#CI_DB_result::list_fields" title="永久链接至目标">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">返回:</th><td class="field-body">Array of column names</td>
</tr>
<tr class="field-even field"><th class="field-name">返回类型:</th><td class="field-body">array</td>
</tr>
</tbody>
</table>
<p>Returns an array containing the field names in the
result set.</p>
</dd></dl>

</dd></dl>

</div>
</div>


          </div>
          <footer>
  
    <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
      
        <a href="helpers.html" class="btn btn-neutral float-right" title="查询辅助函数">下一个主题 <span class="fa fa-arrow-circle-right"></span></a>
      
      
        <a href="queries.html" class="btn btn-neutral" title="查询"><span class="fa fa-arrow-circle-left"></span> 上一个主题</a>
      
    </div>
  

  
  <div id="notes">
  
  <!-- 多说评论框 start -->
    <div class="ds-thread" data-thread-key="userguide3/database/results" data-title="生成查询结果" data-url="http://codeigniter.org.cn/user_guide/database/results.html"></div>
  <!-- 多说评论框 end -->
  

  <div class="ds-share flat" data-thread-key="userguide3/database/results" data-title="生成查询结果 &mdash; CodeIgniter 3.0.0 中文手册|用户手册|用户指南|中文文档" data-url="http://codeigniter.org.cn/user_guide/database/results.html" data-images="" data-content="">
    <div class="ds-share-inline">
      <ul  class="ds-share-icons-16">

        <li data-toggle="ds-share-icons-more"><a class="ds-more" href="javascript:void(0);">分享到：</a></li>
        <li><a class="ds-weibo" href="javascript:void(0);" data-service="weibo">微博</a></li>
        <li><a class="ds-qzone" href="javascript:void(0);" data-service="qzone">QQ空间</a></li>
        <li><a class="ds-qqt" href="javascript:void(0);" data-service="qqt">腾讯微博</a></li>
        <li><a class="ds-wechat" href="javascript:void(0);" data-service="wechat">微信</a></li>

      </ul>
      <div class="ds-share-icons-more">
      </div>
    </div>
  </div>

  <!-- 多说公共JS代码 start (一个网页只需插入一次) -->
  <script type="text/javascript">
    var duoshuoQuery = {short_name:"codeigniter"};
    (function() {
        var ds = document.createElement('script');
        ds.type = 'text/javascript';ds.async = true;
        ds.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') + '//static.duoshuo.com/embed.js';
        ds.charset = 'UTF-8';
        (document.getElementsByTagName('head')[0]
         || document.getElementsByTagName('body')[0]).appendChild(ds);
    })();
    </script>
  <!-- 多说公共JS代码 end -->
  </div>
  

  <hr/>

  <div role="contentinfo">
    <p>
        &copy; 版权所有 2014 - 2015, 不列颠哥伦比亚理工学院.
       最后修改: 2015-10-11.
    </p>

    <p>以 <a href="http://www.aneasystone.com/" target="_blank">aneasystone</a> 制作的手册为基础构建</p>
  </div>

  
    <p>基于 <a href="http://sphinx-doc.org/">Sphinx</a> 并使用 <a href="https://readthedocs.org">Read the Docs</a> 提供的<a href="https://github.com/snide/sphinx_rtd_theme">风格</a>构建</p>
    <p>
        <a href="https://github.com/CodeIgniter-Chinese/codeigniter-user-guide" target="_blank">Github 简体中文翻译</a>
        ·
        <a href="http://codeigniter-chinese.github.io/codeigniter-user-guide/codeigniter_user_guide.zip">离线版压缩包下载</a>
        ·
        <a href="http://codeigniter-chinese.github.io/codeigniter-user-guide/CodeIgniter.pdf">PDF 版下载</a>
    </p>
  

</footer>
        </div>
      </div>

    </section>

  </div>
  

  

    <script type="text/javascript">
        var DOCUMENTATION_OPTIONS = {
            URL_ROOT:'../',
            VERSION:'3.0.2',
            COLLAPSE_INDEX:false,
            FILE_SUFFIX:'.html',
            HAS_SOURCE:  false
        };
    </script>
      <script type="text/javascript" src="../_static/jquery.js"></script>
      <script type="text/javascript" src="../_static/underscore.js"></script>
      <script type="text/javascript" src="../_static/doctools.js"></script>
      <script type="text/javascript" src="../_static/translations.js"></script>

  

  
  
    <script type="text/javascript" src="../_static/js/theme.js"></script>
  

  
  
  <script type="text/javascript">
      jQuery(function () {
          SphinxRtdTheme.StickyNav.enable();
      });
  </script>
   

  
    <script>
        (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
        (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
        m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
        })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

        ga('create', 'UA-272152-3', 'auto');
        ga('send', 'pageview');
    </script>
  

</body>
</html>